package com.zhangzhan.gulimallproduct.web;

import com.zhangzhan.gulimallproduct.service.ItemService;
import com.zhangzhan.gulimallproduct.vos.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.concurrent.ExecutionException;

/**
 * @author 张一恒
 * @version 1.0
 * @description:
 * @date 2024/6/26 4:43
 */
@Controller
public class ItemController {

    @Autowired
    private ItemService itemService;

    @RequestMapping(value = {"/{skuId}/.html"}, method = RequestMethod.GET)
    public String item(Model model, @PathVariable("skuId") Long skuId) throws ExecutionException, InterruptedException {

        SkuItemVo skuItemVo = itemService.getItemData(skuId);
        model.addAttribute("item",skuItemVo);
        return "item";
    }

}
